import ButtionRender1 from '@/components/aggridCellRenDerer/buttionRender1.vue'
import tagRender from '@/components/aggridCellRenDerer/tagRender.vue'
import SearchSelect from '@/components/aggridCellRenDerer/SearchSelect.vue'
import { ref } from 'vue'
import emitter from '@/hooks/useEventBus'
const tableColumns: any = [
  // {
  //   headerCheckboxSelection: true,
  //   checkboxSelection: true,
  //   width: 50,
  //   showDisabledCheckboxes: false,
  //   pinned: 'left',
  // },
  {
    headerName: '退坯单号',
    field: 'deliveryCode',
    width: 150,
  },
  {
    headerName: '开单日期',
    field: 'makeDate',
    width: 150,
  },
  {
    headerName: '客户名称',
    field: 'customName',
    width: 150,
  },
  {
    headerName: '计划单号',
    field: 'planOrderCode',
    width: 150,
  },
  {
    headerName: '坯布编号',
    field: 'greyCode',
    width: 150,
  },
  {
    headerName: '坯布名称',
    field: 'greyName',
    width: 150,
  },
  {
    headerName: '验后重量',
    field: 'weight',
    width: 150,
  },
  {
    headerName: '匹数',
    field: 'horseNum',
    width: 150,
  },
  {
    headerName: '门幅',
    field: 'width',
    width: 150,
  },
  {
    headerName: '克重',
    field: 'grawWeight',
    width: 150,
  },
  {
    headerName: '尺寸',
    field: 'workDrum',
    width: 150,
  },
  {
    headerName: '纱支',
    field: 'yarnCount',
    width: 150,
  },
  {
    headerName: '送货单位',
    field: 'deliveryCompanyName',
    width: 150,
  },
  {
    headerName: '审核人',
    field: 'auditName',
    width: 150,
  },
  {
    headerName: '审核日期',
    field: 'auditDate',
    width: 150,
  },
  {
    headerName: '修改人',
    field: 'updateName',
    width: 150,
  },
  {
    headerName: '修改日期',
    field: 'updateTime',
    width: 150,
  },
  {
    headerName: '入库状态',
    field: 'stockInState',
    width: 150,
    pinned: 'right',
    valueGetter: (params: any) => {
      return params.data.stockInState == 0 ? '未入库' : params.data.stockInState == 1 ? '已入库' : ''
    }
  },
  {
    headerName: '操作',
    field: 'action',
    width: 150,
    pinned: 'right',
    cellRenderer: ButtionRender1,
    cellRendererParams: (params: any) => {
      return {
        buttonList: [
          {
            type: params.data.stockInState == 1 ? 'info' : 'primary',
            text: '入库',
            show: true,
            disabled: params.data.stockInState == 1 ? true : false,
            typeName: 'el-button',
            Callback: (data: any) => {
              return {
                rowData: data,
                emitString: 'ReturnGrayInStock-PendingInStockHandle'
              }
            },
          },
        ],
        eltagSize: 0,
      }
    }
  },
]
const tableColumns2: any = [
  {
    headerName: '客户名称',
    field: 'customName',
    width: 150,
  },
  {
    headerName: '织布单号',
    field: 'planOrderCode',
    width: 150,
  },
  {
    headerName: '坯布编号',
    field: 'greyCode',
    width: 150,
  },
  {
    headerName: '坯布名称',
    field: 'greyName',
    width: 150,
  },
  {
    headerName: '坯布批号',
    field: 'greyBatchNo',
    width: 150,
  },
  {
    headerName: '原料编号',
    field: 'rawmaterialCode',
    width: 150,
  },
  {
    headerName: '原料名称',
    field: 'rawmaterialName',
    width: 150,
  },
  {
    headerName: '纱批',
    field: 'yarnBatch',
    width: 150,
  },
  {
    headerName: '成品门幅',
    field: 'width',
    width: 150,
  },
  {
    headerName: '成品克重',
    field: 'gramWeight',
    width: 150,
  },
  {
    headerName: '可配色称',
    field: 'matchColor',
    width: 150,
  },
  {
    headerName: '针寸',
    field: 'workDrum',
    width: 150,
  },
  {
    headerName: '等级',
    field: 'grade',
    width: 150,
  },
  {
    headerName: '机台',
    field: 'machineCode',
    width: 150,
  },
  {
    headerName: '匹数',
    field: 'horseNum',
    width: 150,
  },
  {
    headerName: '重量',
    field: 'weight',
    width: 150,
  },
  {
    headerName: '布笼',
    field: 'shelveCode',
    width: 150,
  }

]
const tableColumns3: any = [
  {
    headerName: '客户名称',
    field: 'customName',
    width: 150,
  },
  {
    headerName: '织布单号',
    field: 'planOrderCode',
    width: 150,
  },
  {
    headerName: '生产日期',
    field: 'tpdh',
    width: 150,
  },
  {
    headerName: '加工单价',
    field: 'processPrice',
    width: 150,
  },
  {
    headerName: '坯布编号',
    field: 'greyCode',
    width: 150,
  },
  {
    headerName: '坯布名称',
    field: 'greyName',
    width: 150,
  },
  {
    headerName: '坯布批号',
    field: 'greyBatchNo',
    width: 150,
  },
  {
    headerName: '原料编号',
    field: 'rawmaterialCode',
    width: 150,
  },
  {
    headerName: '原料名称',
    field: 'rawmaterialName',
    width: 150,
  },
  {
    headerName: '纱批',
    field: 'yarnBatch',
    width: 150,
  },
  {
    headerName: '成品门幅',
    field: 'width',
    width: 150,
  },
  {
    headerName: '成品克重',
    field: 'gramWeight',
    width: 150,
  },
  {
    headerName: '可配色称',
    field: 'matchColor',
    width: 150,
  },
  {
    headerName: '针寸',
    field: 'workDrum',
    width: 150,
  },
  {
    headerName: '等级',
    field: 'grade',
    width: 150,
  },
  {
    headerName: '条形码',
    field: 'clothfiyCode',
    width: 150,
  },
  {
    headerName: '机台',
    field: 'machineCode',
    width: 150,
  },
  {
    headerName: '机布号',
    field: 'machineGreyCode',
    width: 150,
  },
  {
    headerName: '匹号',
    field: 'horseNo',
    width: 150,
  },
  {
    headerName: '重量',
    field: 'weight',
    width: 150,
  },
  {
    headerName: '布笼',
    field: 'shelveCode',
    width: 150,
  },
  {
    headerName: '单位',
    field: 'unit',
    width: 150,
  },
  {
    headerName: '制版费',
    field: 'plateCost',
    width: 150,
  },
]
const tableColumns4: any = [
  {
    headerCheckboxSelection: true,
    checkboxSelection: true,
    width: 50,
    showDisabledCheckboxes: false,
    pinned: 'left',
  },
  {
    headerName: '退坯单号',
    field: 'deliveryCode',
    width: 150,
  },
  {
    headerName: '入库单号',
    field: 'stockInCode',
    width: 150,
  },
  {
    headerName: '送货单位',
    field: 'deliveryCompanyName',
    width: 150,
  },
  {
    headerName: '公司',
    field: 'companyName',
    width: 150,
  },
  {
    headerName: '客户名称',
    field: 'customName',
    width: 150,
  },
  {
    headerName: '匹数',
    field: 'totalNum',
    width: 150,
  },
  {
    headerName: '重量',
    field: 'totalWeight',
    width: 150,
  },
  {
    headerName: '单位',
    field: 'unit',
    width: 150,
  },
  {
    headerName: '创建人',
    field: 'createName',
    width: 150,
  },
  {
    headerName: '创建时间',
    field: 'createTime',
    width: 150,
  },
  {
    headerName: '修改人',
    field: 'updateName',
    width: 150,
  },
  {
    headerName: '修改时间',
    field: 'updateTime',
    width: 150,
  },
  {
    headerName: '状态',
    field: 'auditState',
    width: 150,
    cellRenderer: tagRender,
    cellRendererParams: {
      styleClass: (params: any) => {
        return params.auditState == 0
          ? 'info'
          : params.auditState == 1
            ? 'success'
            : params.auditState == 2
              ? 'danger'
              : ''
      },
      text: (params: any) => {
        return params.auditState == 0
          ? '待审核'
          : params.auditState == 1
            ? '审核通过'
            : params.auditState == 2
              ? '审核驳回'
              : ''
      },
      eltagSize: 0,
    },
    filterParams: {
      valueFormatter: function (params: any) {
        return params.value == '0' ? '待审核' : params.value == '1' ? '审核通过' : params.value == 2 ? '审核驳回' : ''
      },
    }
  },
  {
    headerName: '备注',
    field: 'remark',
    width: 150,
  },
  {
    headerName: '操作',
    field: 'action',
    width: 150,
    pinned: 'right',
    cellRenderer: ButtionRender1,
    cellRendererParams: {
      buttonList: [
        {
          type: 'primary',
          text: '详情',
          show: true,
          typeName: 'el-button',
          Callback: (data: any) => {
            return {
              rowData: data,
              emitString: 'ReturnGrayInStock-ProcessedDetailHandle'
            }
          },
        },
      ],
      eltagSize: 0,
    },
  },
]
const tableColumns5: any = [
  {
    headerName: '客户名称',
    field: 'customName',
    width: 150,
  },
  {
    headerName: '织布单号',
    field: 'planOrderCode',
    width: 150,
  },
  {
    headerName: '生产日期',
    field: 'tpdh',
    width: 150,
  },
  {
    headerName: '加工单价',
    field: 'processPrice',
    width: 150,
  },
  {
    headerName: '坯布编号',
    field: 'greyCode',
    width: 150,
  },
  {
    headerName: '坯布名称',
    field: 'greyName',
    width: 150,
  },
  {
    headerName: '坯布批号',
    field: 'greyBatchNo',
    width: 150,
  },
  {
    headerName: '原料编号',
    field: 'rawmaterialCode',
    width: 150,
  },
  {
    headerName: '原料名称',
    field: 'rawmaterialName',
    width: 150,
  },
  {
    headerName: '纱批',
    field: 'yarnBatch',
    width: 150,
  },
  {
    headerName: '成品门幅',
    field: 'width',
    width: 150,
  },
  {
    headerName: '成品克重',
    field: 'gramWeight',
    width: 150,
  },
  {
    headerName: '可配色称',
    field: 'matchColor',
    width: 150,
  },
  {
    headerName: '针寸',
    field: 'workDrum',
    width: 150,
  },
  {
    headerName: '等级',
    field: 'grade',
    width: 150,
  },
  {
    headerName: '条形码',
    field: 'clothfiyCode',
    width: 150,
  },
  {
    headerName: '机台',
    field: 'machineCode',
    width: 150,
  },
  {
    headerName: '机布号',
    field: 'machineGreyCode',
    width: 150,
  },
  {
    headerName: '匹号',
    field: 'horseNo',
    width: 150,
  },
  {
    headerName: '重量',
    field: 'weight',
    width: 150,
  },
  {
    headerName: '布笼',
    field: 'shelveCode',
    width: 150,
    // pinned: 'right',
    cellRenderer: SearchSelect,
    cellRendererParams: (params: any) => {
      return {
        url: 'wms/shelve/getFieldValueOption',
        value: params.data['shelveCode'],
        changeVal: (obj: Object) => {
          params.data['shelveCode'] = obj['shelveCode']
          params.data['shelveId'] = obj['id']
        }
      }
    },
  },
  {
    headerName: '单位',
    field: 'unit',
    width: 150,
  },
  {
    headerName: '制版费',
    field: 'plateCost',
    width: 150,
  },
]
export {
  tableColumns,
  tableColumns2,
  tableColumns3,
  tableColumns4,
  tableColumns5
}
const table4EmitRef = ref(null)
emitter.on('pending-table4Ref', (table4Ref: any) => table4EmitRef.value = table4Ref.value)